package com.cccyy.data.map;

import com.alibaba.fastjson2.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

public class IsEmpty {
    private static final Logger log = LoggerFactory.getLogger(IsEmpty.class);

    public static void main(String[] args) {
        HashMap<String, Object> map = new HashMap<>();
        if (map.isEmpty()) {
            if (null == map) {
                log.info("map是空的-null");
            } else {
                log.info("map是空的");
            }
        } else {
            log.info("map不是空的");
        }
        HashMap<String, Object> headMap = new HashMap<>();
        headMap.put("sysCode", "000100");
        map.put("sysHead", headMap);
        map.put("bodyJson", "1111");
        map.put("str", "");
        map.put("nu", null);
        Object sysHead = map.get("sysHead");
        log.info("sysHead值为：{}", sysHead);
        Object bodyJson = map.get("bodyJson");
        log.info("bodyJson值为：{}", bodyJson);

        Object str = map.get("str");
        log.info("str值为：{}", str);

//        Map strMap = (Map) map.get("str");//转换失败
//        log.info("strMap值为：{}", strMap);

        Object nu = map.get("nu");
        log.info("nu值为：{}", nu);
        Map nuMap = (Map) map.get("nu");
        log.info("nuMap值为：{}", nuMap);

        map = null;
        map.put("sss", "sss");
        log.info("map重新赋值为：{}", JSON.toJSON(map));

    }
}
